#include "itemsetdialog.h"
#include "ui_itemsetdialog.h"

ItemSetDialog::ItemSetDialog(MyGraphicsItem *item, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ItemSetDialog)
{
    this->item = item;
    ui->setupUi(this);
    if(item->myType().at(0).toAscii() == 's')
    {
        ui->leftLabel->setEnabled(false);
        ui->leftLcdNumber->setEnabled(false);
        ui->leftVerticalSlider->setEnabled(false);
        ui->rightLabel->setEnabled(false);
        ui->rightLcdNumber->setEnabled(false);
        ui->rightVerticalSlider->setEnabled(false);
        ui->timeSpinBox->setValue(item->timeLenght());
    }
    else
    {
        ui->leftVerticalSlider->setValue(item->leftHeight());
        ui->rightVerticalSlider->setValue(item->rightHeight());
        ui->timeSpinBox->setValue(item->timeLenght());
    }
    connect(ui->leftVerticalSlider, SIGNAL(valueChanged(int)), this, SLOT(leftValueChanged(int)));
    connect(ui->rightVerticalSlider, SIGNAL(valueChanged(int)), this, SLOT(rightValueChanged(int)));
    connect(ui->timeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(timeValueChanged(int)));
}

void ItemSetDialog::leftValueChanged(int i)
{
    qDebug()<<"leftValueChanged";
    item->setLeftHeight(i);
}

void ItemSetDialog::rightValueChanged(int i)
{
    qDebug()<<"rightValueChanged";
    item->setRightHeight(i);
}

void ItemSetDialog::timeValueChanged(int i)
{
    item->setTimeLenght(i);
}

ItemSetDialog::~ItemSetDialog()
{
    delete ui;
}
